package com.gary.spring.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author peng_rui
 * @date 2022/6/21
 */
@Component
public class LifeCycle {
    public LifeCycle() {
        System.out.println("lifeCycle 执行构造方法。。。");
    }

    @Autowired
    public String getHome(@Value("${JAVA_HOME}") String home) {
        System.out.println("执行依赖注入。。。");
        return home;
    }

    @PostConstruct
    public void init() {
        System.out.println("执行初始化方法。。。");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("销毁。。。");
    }
}
